<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head>
<title>User list</title>
<script type="text/javascript" src="../../js/include.js"></script>
<script type="text/javascript">
//删除
function del(){
	var row = $("#dg").datagrid('getSelections');
	if(row.length!=0) {
		 $.messager.confirm("确认", "确认删除吗？", function (r) {
		        if (r) {
		        	var myArray=new Array();
		        	for(var i=0;i<row.length;i++){
		        		myArray.push(row[i].id);
		        	}
		        	$.ajax({   
					     url:url+'/system/dict/delete',   
					     type:'post',   
					     data:"id="+myArray,
					     success:function(data){   
					    		
						        if(data.result=="success"){
						        	window.location=htmlURL+"/system/dict/list.html";
						        }else{
						        	$.messager.alert('提示',data.msg);
						        }
					     }
					});
		        }
		 });
	}else{
		$.messager.alert('提示','请选择一条');
	}
}
function cx(){
	var obj=$("#searchFrom").serializeObject(); 
	$.ajax({
             url:url+"/system/dict/list",
             data:obj,
             type:'post',
             success:function(data){
                	$('#dg').datagrid('loadData',data.data);
             }
        });
}
//弹窗修改
function upd(){
	var row =  $("#dg").datagrid('getSelections');
	if(row.length==1){
		window.location=htmlURL+"/system/dict/update.html?id="+row[0].id;
	}else{
		$.messager.alert('提示','请选择一条');
	}
}
function add(){
	window.location=htmlURL+"/system/dict/add.html";
}

$(function(){
    if(!getResources("/system/dict/add")){
        $('#add').hide();
	}

	if(!getResources("/system/dict/update")){
        $('#update').hide();
	}

	if(!getResources("/system/dict/delete")){
        $('#delete').hide();
	}
	cx();
}); 
</script>
</head>
<body>
  	
   <table id="dg"  class="easyui-datagrid"  fit="true" 
           
            toolbar="#toolbar" pagination="true"
            rownumbers="true" fitColumns="true" singleSelect="false" >
        <thead>
            <tr>
               	<th field=""  data-options="checkbox:true"></th>
                <th field="code" width="50">编码</th>
                <th field="name" width="50">名称</th>
                <th field="type" width="50">类型</th>
            </tr>
        </thead>
    </table>
    <div id="toolbar">
    	<form id="searchFrom" action="">
			名称:<input type="text" name="name" class="easyui-validatebox" />
			类型:<input type="text" name="type" class="easyui-validatebox" />
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="cx()">查询</a><br>
		</form>
	        <a id="add" href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="add()">新增</a>
	        <a id="update" href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="upd()">编辑</a>
	        <a id="delete" href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="del()">删除</a>
    </div>

</body>
</html>